Skip to content

Conversation

@strawgate
Copy link
Contributor

@strawgate strawgate commented Sep 3, 2025

Fixes: #2406

Introduces a FastMCPToolset which can take a FastMCP Client, a FastMCP Server, a config for an MCP Server, or an MCP JSON config.

This enables running FastMCP Servers in-memory, running Stdio servers via FastMCP, connecting to remote MCP Servers, transforming tools, etc.

Todo:

  • Add tests
  • Update docs
  • Coverage

@strawgate strawgate changed the title Add FastMCP Toolset Add FastMCPToolset Sep 3, 2025
@strawgate strawgate force-pushed the fastmcp-toolset branch 3 times, most recently from f68660d to 54367c8 Compare September 4, 2025 22:13
@strawgate
Copy link
Contributor Author

@DouweM this is ready for review when you have a chance

@DouweM DouweM self-assigned this Sep 8, 2025
@strawgate
Copy link
Contributor Author

strawgate commented Sep 12, 2025

Basically I had implemented the content handling here, gotten annoyed at how weird it was, and then went and fixed it in FastMCP --

Once the next version of FastMCP comes out I was going to simplify the content handling here and return structured content if it's available and only return content if it's not (which I'm sure is what the MCP code was doing).

Will incorporate the feedback tomorrow and work on simpler examples

@github-actions
Copy link

This PR is stale, and will be closed in 3 days if no reply is received.

@github-actions github-actions bot added the Stale label Sep 20, 2025
@DouweM DouweM removed the Stale label Sep 20, 2025
docs/toolsets.md Outdated

See the [MCP Client](./mcp/client.md) documentation for how to use MCP servers with Pydantic AI.

### FastMCP Tools {#fastmcp-tools}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: before merging this, see if it makes sense to move this to a separate doc that can be listed in the "MCP" section in the sidebar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some changes in this direction

@strawgate
Copy link
Contributor Author

I think i may hold off on resource link support for now if that's okay. My guess is we'd want a kwarg that adds an optional tool for reading resources and maybe even list/read prompts from the target server?

@DouweM
Copy link
Collaborator

DouweM commented Oct 13, 2025

@strawgate Agreed, we have to do some work on MCP resource links anyway: #3099

@DouweM
Copy link
Collaborator

DouweM commented Oct 13, 2025

@strawgate test_fastmcp is failing when the package is not installed :) I'll review this later today!

### Security

MCP Elicitation requires careful handling - servers must not request sensitive information, and clients must implement user approval controls with clear explanations. See [security considerations](https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#security-considerations) for details.
The [FastMCP-based Client](./fastmcp-client.md) offers a higher-level API with additional capabilities like Tool Transformation, simpler OAuth configuration, and more.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also list anything the native client does support that FastMCP doesn't yet. Either here as, "supports X but not Y", or above.

@github-actions
Copy link

This PR is stale, and will be closed in 3 days if no reply is received.

@github-actions github-actions bot added the Stale label Oct 20, 2025
@strawgate
Copy link
Contributor Author

Not stale!

@github-actions github-actions bot removed the Stale label Oct 21, 2025
# Conflicts:
#	docs/mcp/client.md
#	uv.lock
@DouweM DouweM enabled auto-merge (squash) October 24, 2025 21:12
@DouweM DouweM merged commit 606643f into pydantic:main Oct 24, 2025
58 of 60 checks passed
@DouweM
Copy link
Collaborator

DouweM commented Oct 24, 2025

@strawgate Thanks for your work here Bill! I found some time to wrap it up :)

@strawgate
Copy link
Contributor Author

🚀 🚀 🚀 🚀 🚀 🚀 🚀 🚀 🚀 🚀

@jlowin
Copy link
Contributor

jlowin commented Oct 24, 2025

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contributing FastMCP Toolset

3 participants